package com.bsoft.ecommerce.controller;

import com.bsoft.ecommerce.account.BalanceInfo;
import com.bsoft.ecommerce.service.IBanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "用户余额服务")
@Slf4j
@RestController
@RequestMapping("/balance")
public class BalanceController {
    @Autowired
    private IBanceService  iBanceService;
    @ApiOperation(value = "当前用户",notes = "获取当前用户的余额信息",httpMethod = "GET")
    @GetMapping("current-balance")
    public BalanceInfo getCurrentbalanceInfo(){
        return iBanceService.getCurrentUserBalanceInfo();
    }
    @ApiOperation(value = "扣减",notes = "扣减用于余额",httpMethod = "PUT")
    @PutMapping("/deduct-balance")
    public  BalanceInfo deduceBalance(@RequestBody BalanceInfo balanceInfo){
   return  iBanceService.deductBalance(balanceInfo);
    }
}
